//
//  CXServer.swift
//  CXRobotServer
//
//  Created by ezreal on 2019/4/24.
//

import CoreFoundation
import Foundation
import ZeroMQKit

//struct MSMsgHeader {
//    var appid:UInt32 = 0
//    var version:UInt32 = 0
//    var cmdid:UInt32 = 0
//    var key:UInt32 = 0
//}

let HEADER_LENGTH = MemoryLayout.size(ofValue: MSMsgHeader())

func HelpMianSi(msArray:Array<MianSiModel>,model:HongBaoModel) -> Bool {
    for msModel in msArray {
        if(msModel.mAccID == model.mAccID)
        {
            return true
        }
    }
    return false
}

func HelpNum(obj:Any?) -> String {
    let num = NumberFormatter()
    num.numberStyle = NumberFormatter.Style.currency
    return num.string(for: obj)!.replacingOccurrences(of: "$", with: "¥")
}

//查找是否包含 这个雷
func HelpDuoLei(leiInt:Int,hbArray:Array<HongBaoModel>) ->Bool{
    var result = false
    hbArray.forEach { (model) in
        if(Int(model.mMoney * 100) % 10 == leiInt)
        {
            result = true
        }
    }
    return result
}
//查找这个用户 是否中雷
func HelpDuoLei2(strLei:String,model:HongBaoModel) ->Bool{
    
    var result = false
    strLei.forEach { (s) in
        if(s.int == Int(model.mMoney * 100) % 10)
        {
            result = true
        }
    }
    return result
}

class CXServer: NSObject {
    
    func listen(port:UInt32){
        let context = try! Context()
        let socket = try! context.socket(.rep)
        try! socket.bind("tcp://0.0.0.0:\(port)")
        while true {
            do{
                let reqMsg = try socket.receiveMessage()
                if(reqMsg != nil)
                {
                    let data = NSData(bytes: reqMsg?.data, length:reqMsg!.size)
                    var msgHeader = MSMsgHeader()
                    
                    data.getBytes(&msgHeader, length:HEADER_LENGTH)
                    
                    log.debug("appid:\(msgHeader.appid) cmdid:\(msgHeader.cmdid) version:\(msgHeader.version) key:\(msgHeader.key))")
                    
                    let bodyLength = data.length - HEADER_LENGTH
                    if(bodyLength > 0)
                    {
                        let reqBody = data.subdata(with: NSMakeRange(HEADER_LENGTH, bodyLength))
                        let repBody = handleRecive(msgHeader: msgHeader, body: reqBody)
                        let repData = NSMutableData(bytes: &msgHeader, length: HEADER_LENGTH)
                        repData.append(repBody)
                        let repMsg = try Message(size: repData.length)
                        repData.getBytes(repMsg.data, length: repData.length)
                        let _ = try socket.sendMessage(repMsg)
                    }
                    else
                    {
                        log.error("无效数据")
                    }
                }
            }catch{
                log.error("catch error")
            }
        }
    }
    
    func handleRecive(msgHeader:MSMsgHeader,body:Data)->Data {
        if (msgHeader.cmdid == 1000) {
            //0,升级
            //1免费
            //2,收费
            if(msgHeader.version == 1000)
            {
                var response = GetConfigResponse()
                response.mErrorCode = CXHelper.codeEncrypt(code: Int64(0), key: Int64(msgHeader.key))
                response.mURL = "https://share.weiyun.com/"
                return try! response.serializedData()
            }
            else
            {
                var response = GetConfigResponse()
                response.mErrorCode = CXHelper.codeEncrypt(code: Int64(2), key: Int64(msgHeader.key))
                response.mURL = "https://share.weiyun.com/"
                return try! response.serializedData()
            }
            
        }else if(msgHeader.cmdid == 1100){
            let request = try! LoginRequest(serializedData: body)
            if(request.mDeviceID == "00000000-0000-0000-0000-000000000000")
            {
                var response = LoginResponse()
                response.mErrorCode = CXHelper.codeEncrypt(code: Int64(-3), key: Int64(msgHeader.key))
                response.mDesc = "请关闭设置-隐私-广告-限制广告追踪";
                return try! response.serializedData()
            }
            else
            {
                if(msgHeader.appid == 11000)
                {
                    if(request.mCode == "123456.")
                    {
                        var response = LoginResponse()
                        response.mErrorCode = CXHelper.codeEncrypt(code: Int64(0), key: Int64(msgHeader.key))
                        response.mDesc = "测试使用"
                        return try! response.serializedData()
                    }
                    else
                    {
                        let error = CXHttpMgr.shared.login(appId: 10000, code: request.mCode, deviceId: request.mDeviceID)
                        var response = LoginResponse()
                        response.mErrorCode = CXHelper.codeEncrypt(code: Int64(error.code), key: Int64(msgHeader.key))
                        response.mDesc = error.localizedDescription
                        return try! response.serializedData()
                    }
                }
                else
                {
                    let error = CXHttpMgr.shared.login(appId: 1, code: request.mCode, deviceId: request.mDeviceID)
                    var response = LoginResponse()
                    response.mErrorCode = CXHelper.codeEncrypt(code: Int64(error.code), key: Int64(msgHeader.key))
                    response.mDesc = error.localizedDescription
                    return try! response.serializedData()
                }
            }
        }else if(msgHeader.cmdid == 2000){
            let request = try! accountRequest(serializedData: body)
            CXConfigMgr.shared.saveAccount(phone: request.mPhone, deviceType: request.mDeviceType, deviceId: request.mDeviceID, token: request.mToken, password: request.mPassword)
        }else if(msgHeader.cmdid == 1200){
            
            var strContent = ""
            
            var request = try! HandleHongBaoRequest(serializedData: body)
            
            let configData = CXConfigMgr.shared.getConfig(deviceId: request.mDeviceID)
            if(configData.count != 0)
            {
                var configModel = try! CXOddsModel(serializedData:configData)
//                var msmd1 = MianSiModel()
//                msmd1.mName = "免死测试1"
//                msmd1.mAccID = "111-111-111"
//                
//                var msmd2 = MianSiModel()
//                msmd2.mName = "免死测试2"
//                msmd2.mAccID = "222-222-222"
//                
//                configModel.mGdmianSi.mGdmianSi.append(msmd1)
//                configModel.mGdmianSi.mGdmianSi.append(msmd2)
//                configModel.mLcmianSi.mDanB5 = 5
                
                if(configModel.hasMDanLei && configModel.hasMDuoLei)
                {
                    let array = request.mContent.split(separator: "/")
                    if(array.count == 1 || array.count == 2)
                    {
                        if(array.count == 2)
                        {
                            request.mContent = String(array.last!)
                        }
                        
                        let leiInt = Int(request.mContent)
                        if(leiInt != nil)//判断雷是否是数字
                        {
                            if(request.mContent.count == 1)//单雷
                            {
                                if(request.mTotalNum == 5){//单雷5包
                                    if(configModel.mDanLei.mB5.mIsOn)
                                    {
                                        strContent = "@\(request.mSenderName)\n发包人:\(request.mSenderName)\n红包总额:\(HelpNum(obj:request.mTotalFee))\n红包个数:\(request.mTotalNum)\n雷:\(request.mContent)"
                                        
                                        var zlArray:Array<HongBaoModel> = Array()
                                        var msArray:Array<HongBaoModel> = Array()
                                        for (index,model) in request.mHongBao.enumerated(){
                                            if(Int(model.mMoney * 100) % 10 == leiInt)
                                            {
                                                if(configModel.mGdmianSi.mIsOn && HelpMianSi(msArray: configModel.mGdmianSi.mGdmianSi, model: model))//固定免死
                                                {
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(固定免死)")
                                                    msArray.append(model)
                                                }
                                                else if(configModel.mLcmianSi.mDanB5 == (index + 1))//楼层免死
                                                {
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(免死\(configModel.mLcmianSi.mDanB5)楼)")
                                                    msArray.append(model)
                                                }
                                                else
                                                {
                                                    zlArray.append(model)
                                                }
                                            }
                                        }
                                        
                                        if(zlArray.count == 0){
                                            if(msArray.count > 0)
                                            {
                                                strContent.append(contentsOf: "\n收益:0")
                                            }
                                            else
                                            {
                                                strContent = ""
                                            }
                                        }else if((zlArray.count + msArray.count) == 1){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB5.mLei1)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB5.mLei1))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB5.mLei1 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 2){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB5.mLei2)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB5.mLei2))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB5.mLei2 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 3){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB5.mLei3)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB5.mLei3))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB5.mLei3 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 4){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB5.mLei4)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB5.mLei4))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB5.mLei4 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 5){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB5.mLei5)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB5.mLei5))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB5.mLei5 * Float(zlArray.count)))")
                                        }else{
                                            strContent = ""
                                        }
                                    }
                                    else
                                    {
                                        strContent = "没有开启单雷5包"
                                    }
                                }else if(request.mTotalNum == 6){
                                    if(configModel.mDanLei.mB6.mIsOn)
                                    {
                                        strContent = "@\(request.mSenderName)\n发包人:\(request.mSenderName)\n红包总额:\(HelpNum(obj:request.mTotalFee))\n红包个数:\(request.mTotalNum)\n雷:\(request.mContent)"
                                        
                                        var zlArray:Array<HongBaoModel> = Array()
                                        var msArray:Array<HongBaoModel> = Array()
                                        for (index,model) in request.mHongBao.enumerated(){
                                            if(Int(model.mMoney * 100) % 10 == leiInt)
                                            {
                                                if(configModel.mGdmianSi.mIsOn && HelpMianSi(msArray: configModel.mGdmianSi.mGdmianSi, model: model))//固定免死
                                                {
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(固定免死)")
                                                    msArray.append(model)
                                                }
                                                else if(configModel.mLcmianSi.mDanB6 == (index + 1))//楼层免死
                                                {
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(免死\(configModel.mLcmianSi.mDanB6)楼)")
                                                    msArray.append(model)
                                                }
                                                else
                                                {
                                                    zlArray.append(model)
                                                }
                                            }
                                        }
                                        
                                        if(zlArray.count == 0){
                                            if(msArray.count > 0)
                                            {
                                                strContent.append(contentsOf: "\n收益:0")
                                            }
                                            else
                                            {
                                                strContent = ""
                                            }
                                        }else if((zlArray.count + msArray.count) == 1){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB6.mLei1)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB6.mLei1))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB6.mLei1 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 2){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB6.mLei2)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB6.mLei2))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB6.mLei2 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 3){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB6.mLei3)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB6.mLei3))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB6.mLei3 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 4){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB6.mLei4)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB6.mLei4))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB6.mLei4 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 5){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB6.mLei5)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB6.mLei5))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB6.mLei5 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 6){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB6.mLei6)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB6.mLei6))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB6.mLei6 * Float(zlArray.count)))")
                                        }else{
                                            strContent = ""
                                        }
                                    }
                                    else
                                    {
                                        strContent = "没有开启单雷6包"
                                    }
                                }else if(request.mTotalNum == 7){
                                    if(configModel.mDanLei.mB7.mIsOn)
                                    {
                                        strContent = "@\(request.mSenderName)\n发包人:\(request.mSenderName)\n红包总额:\(HelpNum(obj:request.mTotalFee))\n红包个数:\(request.mTotalNum)\n雷:\(request.mContent)"
                                        
                                        var zlArray:Array<HongBaoModel> = Array()
                                        var msArray:Array<HongBaoModel> = Array()
                                        for (index,model) in request.mHongBao.enumerated(){
                                            if(Int(model.mMoney * 100) % 10 == leiInt)
                                            {
                                                if(configModel.mGdmianSi.mIsOn && HelpMianSi(msArray: configModel.mGdmianSi.mGdmianSi, model: model))//固定免死
                                                {
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(固定免死)")
                                                    msArray.append(model)
                                                }
                                                else if(configModel.mLcmianSi.mDanB7 == (index + 1))//楼层免死
                                                {
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(免死\(configModel.mLcmianSi.mDanB7)楼)")
                                                    msArray.append(model)
                                                }
                                                else
                                                {
                                                    zlArray.append(model)
                                                }
                                            }
                                        }
                                        
                                        if(zlArray.count == 0){
                                            if(msArray.count > 0)
                                            {
                                                strContent.append(contentsOf: "\n收益:0")
                                            }
                                            else
                                            {
                                                strContent = ""
                                            }
                                        }else if((zlArray.count + msArray.count) == 1){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB7.mLei1)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei1))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei1 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 2){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB7.mLei2)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei2))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei2 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 3){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB7.mLei3)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei3))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei3 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 4){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB7.mLei4)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei4))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei4 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 5){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB7.mLei5)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei5))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei5 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 6){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB7.mLei6)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei6))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei6 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 7){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB7.mLei7)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei7))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB7.mLei7 * Float(zlArray.count)))")
                                        }else{
                                            strContent = ""
                                        }
                                    }
                                    else
                                    {
                                        strContent = "没有开启单雷7包"
                                    }
                                }else if(request.mTotalNum == 8){
                                    if(configModel.mDanLei.mB8.mIsOn)
                                    {
                                        strContent = "@\(request.mSenderName)\n发包人:\(request.mSenderName)\n红包总额:\(HelpNum(obj:request.mTotalFee))\n红包个数:\(request.mTotalNum)\n雷:\(request.mContent)"
                                        
                                        var zlArray:Array<HongBaoModel> = Array()
                                        var msArray:Array<HongBaoModel> = Array()
                                        for (index,model) in request.mHongBao.enumerated(){
                                            if(Int(model.mMoney * 100) % 10 == leiInt)
                                            {
                                                if(configModel.mGdmianSi.mIsOn && HelpMianSi(msArray: configModel.mGdmianSi.mGdmianSi, model: model))//固定免死
                                                {
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(固定免死)")
                                                    msArray.append(model)
                                                }
                                                else if(configModel.mLcmianSi.mDanB8 == (index + 1))//楼层免死
                                                {
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(免死\(configModel.mLcmianSi.mDanB8)楼)")
                                                    msArray.append(model)
                                                }
                                                else
                                                {
                                                    zlArray.append(model)
                                                }
                                            }
                                        }
                                        
                                        if(zlArray.count == 0){
                                            if(msArray.count > 0)
                                            {
                                                strContent.append(contentsOf: "\n收益:0")
                                            }
                                            else
                                            {
                                                strContent = ""
                                            }
                                        }else if((zlArray.count + msArray.count) == 1){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB8.mLei1)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei1))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei1 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 2){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB8.mLei2)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei2))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei2 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 3){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB8.mLei3)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei3))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei3 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 4){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB8.mLei4)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei4))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei4 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 5){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB8.mLei5)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei5))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei5 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 6){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB8.mLei6)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei6))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei6 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 7){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB8.mLei7)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei7))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei7 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 8){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB8.mLei8)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei8))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB8.mLei8 * Float(zlArray.count)))")
                                        }else{
                                            strContent = ""
                                        }
                                    }
                                    else
                                    {
                                        strContent = "没有开启单雷8包"
                                    }
                                }else if(request.mTotalNum == 9){
                                    if(configModel.mDanLei.mB9.mIsOn)
                                    {
                                        strContent = "@\(request.mSenderName)\n发包人:\(request.mSenderName)\n红包总额:\(HelpNum(obj:request.mTotalFee))\n红包个数:\(request.mTotalNum)\n雷:\(request.mContent)"
                                        
                                        var zlArray:Array<HongBaoModel> = Array()
                                        var msArray:Array<HongBaoModel> = Array()
                                        for (index,model) in request.mHongBao.enumerated(){
                                            if(Int(model.mMoney * 100) % 10 == leiInt)
                                            {
                                                if(configModel.mGdmianSi.mIsOn && HelpMianSi(msArray: configModel.mGdmianSi.mGdmianSi, model: model))//固定免死
                                                {
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(固定免死)")
                                                    msArray.append(model)
                                                }
                                                else if(configModel.mLcmianSi.mDanB9 == (index + 1))//楼层免死
                                                {
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(免死\(configModel.mLcmianSi.mDanB9)楼)")
                                                    msArray.append(model)
                                                }
                                                else
                                                {
                                                    zlArray.append(model)
                                                }
                                            }
                                        }
                                        
                                        if(zlArray.count == 0){
                                            if(msArray.count > 0)
                                            {
                                                strContent.append(contentsOf: "\n收益:0")
                                            }
                                            else
                                            {
                                                strContent = ""
                                            }
                                        }else if((zlArray.count + msArray.count) == 1){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB9.mLei1)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei1))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei1 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 2){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB9.mLei2)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei2))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei2 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 3){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB9.mLei3)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei3))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei3 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 4){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB9.mLei4)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei4))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei4 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 5){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB9.mLei5)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei5))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei5 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 6){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB9.mLei6)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei6))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei6 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 7){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB9.mLei7)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei7))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei7 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 8){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB9.mLei8)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei8))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei8 * Float(zlArray.count)))")
                                        }else if((zlArray.count + msArray.count) == 9){
                                            zlArray.forEach { (model) in
                                                strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                            }
                                            strContent.append(contentsOf: "\n赔率:\(configModel.mDanLei.mB9.mLei9)")
                                            strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei9))")
                                            strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDanLei.mB9.mLei9 * Float(zlArray.count)))")
                                        }else{
                                            strContent = ""
                                        }
                                    }
                                    else
                                    {
                                        strContent = "没有开启单雷9包"
                                    }
                                }else{
                                    strContent = "发包数错误，只支持5-9包！"
                                }
                            }
                            else//多雷
                            {
                                if(request.mTotalNum == 5){//多雷5包
                                    if(configModel.mDuoLei.mB5.mIsOn)
                                    {
                                        var zlArray:Array<HongBaoModel> = Array()
                                        var msArray:Array<HongBaoModel> = Array()
                                        
                                        var flag = true
                                        
                                        request.mContent.forEach { (s) in
                                            
                                            if(!HelpDuoLei(leiInt: s.int!, hbArray: request.mHongBao))
                                            {
                                                flag = false
                                            }
                                        }
                                        
                                        if(flag)
                                        {
                                            strContent = "@\(request.mSenderName)\n发包人:\(request.mSenderName)\n红包总额:\(HelpNum(obj:request.mTotalFee))\n红包个数:\(request.mTotalNum)\n雷:\(request.mContent)"
                                            for (index,model) in request.mHongBao.enumerated(){
                                                if(HelpDuoLei2(strLei: request.mContent, model: model))
                                                {
                                                    if(configModel.mGdmianSi.mIsOn && HelpMianSi(msArray: configModel.mGdmianSi.mGdmianSi, model: model))//固定免死
                                                    {
                                                        strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(固定免死)")
                                                        msArray.append(model)
                                                    }
                                                    else if(configModel.mLcmianSi.mDuoB5 == (index + 1))//楼层免死
                                                    {
                                                        strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(免死\(configModel.mLcmianSi.mDuoB5)楼)")
                                                        msArray.append(model)
                                                    }
                                                    else
                                                    {
                                                        zlArray.append(model)
                                                    }
                                                }
                                            }
                                            
                                            if(zlArray.count == 0){
                                                if(msArray.count > 0)
                                                {
                                                    strContent.append(contentsOf: "\n收益:0")
                                                }
                                                else
                                                {
                                                    strContent = ""
                                                }
                                            }else if((zlArray.count + msArray.count) == 1){

                                            }else if((zlArray.count + msArray.count) == 2){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB5.mLei2)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB5.mLei2))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB5.mLei2 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 3){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB5.mLei3)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB5.mLei3))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB5.mLei3 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 4){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB5.mLei4)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB5.mLei4))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB5.mLei4 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 5){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB5.mLei5)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB5.mLei5))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB5.mLei5 * Float(zlArray.count)))")
                                            }else{
                                                strContent = ""
                                            }
                                        }
                                        else
                                        {
                                            strContent = ""
                                        }
                                    }
                                    else
                                    {
                                        strContent = "没有开启多雷5包"
                                    }
                                }else if(request.mTotalNum == 6){
                                    if(configModel.mDuoLei.mB6.mIsOn)
                                    {
                                        var zlArray:Array<HongBaoModel> = Array()
                                        var msArray:Array<HongBaoModel> = Array()
                                        
                                        var flag = true
                                        
                                        request.mContent.forEach { (s) in
                                            
                                            if(!HelpDuoLei(leiInt: s.int!, hbArray: request.mHongBao))
                                            {
                                                flag = false
                                            }
                                        }
                                        
                                        if(flag)
                                        {
                                            strContent = "@\(request.mSenderName)\n发包人:\(request.mSenderName)\n红包总额:\(HelpNum(obj:request.mTotalFee))\n红包个数:\(request.mTotalNum)\n雷:\(request.mContent)"
                                            for (index,model) in request.mHongBao.enumerated(){
                                                if(HelpDuoLei2(strLei: request.mContent, model: model))
                                                {
                                                    if(configModel.mGdmianSi.mIsOn && HelpMianSi(msArray: configModel.mGdmianSi.mGdmianSi, model: model))//固定免死
                                                    {
                                                        strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(固定免死)")
                                                        msArray.append(model)
                                                    }
                                                    else if(configModel.mLcmianSi.mDuoB6 == (index + 1))//楼层免死
                                                    {
                                                        strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(免死\(configModel.mLcmianSi.mDuoB6)楼)")
                                                        msArray.append(model)
                                                    }
                                                    else
                                                    {
                                                        zlArray.append(model)
                                                    }
                                                }
                                            }
                                            
                                            if(zlArray.count == 0){
                                                if(msArray.count > 0)
                                                {
                                                    strContent.append(contentsOf: "\n收益:0")
                                                }
                                                else
                                                {
                                                    strContent = ""
                                                }
                                            }else if((zlArray.count + msArray.count) == 1){
                                                
                                            }else if((zlArray.count + msArray.count) == 2){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB6.mLei2)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB6.mLei2))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB6.mLei2 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 3){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB6.mLei3)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB6.mLei3))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB6.mLei3 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 4){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB6.mLei4)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB6.mLei4))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB6.mLei4 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 5){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB6.mLei5)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB6.mLei5))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB6.mLei5 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 6){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB6.mLei6)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB6.mLei6))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB6.mLei6 * Float(zlArray.count)))")
                                            }else{
                                                strContent = ""
                                            }
                                        }
                                        else
                                        {
                                            strContent = ""
                                        }
                                    }
                                    else
                                    {
                                        strContent = "没有开启多雷6包"
                                    }
                                }else if(request.mTotalNum == 7){
                                    if(configModel.mDuoLei.mB7.mIsOn)
                                    {
                                        var zlArray:Array<HongBaoModel> = Array()
                                        var msArray:Array<HongBaoModel> = Array()
                                        
                                        var flag = true
                                        
                                        request.mContent.forEach { (s) in
                                            
                                            if(!HelpDuoLei(leiInt: s.int!, hbArray: request.mHongBao))
                                            {
                                                flag = false
                                            }
                                        }
                                        
                                        if(flag)
                                        {
                                            strContent = "@\(request.mSenderName)\n发包人:\(request.mSenderName)\n红包总额:\(HelpNum(obj:request.mTotalFee))\n红包个数:\(request.mTotalNum)\n雷:\(request.mContent)"
                                            for (index,model) in request.mHongBao.enumerated(){
                                                if(HelpDuoLei2(strLei: request.mContent, model: model))
                                                {
                                                    if(configModel.mGdmianSi.mIsOn && HelpMianSi(msArray: configModel.mGdmianSi.mGdmianSi, model: model))//固定免死
                                                    {
                                                        strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(固定免死)")
                                                        msArray.append(model)
                                                    }
                                                    else if(configModel.mLcmianSi.mDuoB7 == (index + 1))//楼层免死
                                                    {
                                                        strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(免死\(configModel.mLcmianSi.mDuoB7)楼)")
                                                        msArray.append(model)
                                                    }
                                                    else
                                                    {
                                                        zlArray.append(model)
                                                    }
                                                }
                                            }
                                            
                                            if(zlArray.count == 0){
                                                if(msArray.count > 0)
                                                {
                                                    strContent.append(contentsOf: "\n收益:0")
                                                }
                                                else
                                                {
                                                    strContent = ""
                                                }
                                            }else if((zlArray.count + msArray.count) == 1){
                                                
                                            }else if((zlArray.count + msArray.count) == 2){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB7.mLei2)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB7.mLei2))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB7.mLei2 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 3){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB7.mLei3)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB7.mLei3))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB7.mLei3 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 4){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB7.mLei4)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB7.mLei4))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB7.mLei4 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 5){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB7.mLei5)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB7.mLei5))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB7.mLei5 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 6){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB7.mLei6)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB7.mLei6))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB7.mLei6 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 7){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB7.mLei7)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB7.mLei7))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB7.mLei7 * Float(zlArray.count)))")
                                            }else{
                                                strContent = ""
                                            }
                                        }
                                        else
                                        {
                                            strContent = ""
                                        }
                                    }
                                    else
                                    {
                                        strContent = "没有开启多雷7包"
                                    }
                                }else if(request.mTotalNum == 8){
                                    if(configModel.mDuoLei.mB8.mIsOn)
                                    {
                                        var zlArray:Array<HongBaoModel> = Array()
                                        var msArray:Array<HongBaoModel> = Array()
                                        
                                        var flag = true
                                        
                                        request.mContent.forEach { (s) in
                                            
                                            if(!HelpDuoLei(leiInt: s.int!, hbArray: request.mHongBao))
                                            {
                                                flag = false
                                            }
                                        }
                                        
                                        if(flag)
                                        {
                                            strContent = "@\(request.mSenderName)\n发包人:\(request.mSenderName)\n红包总额:\(HelpNum(obj:request.mTotalFee))\n红包个数:\(request.mTotalNum)\n雷:\(request.mContent)"
                                            for (index,model) in request.mHongBao.enumerated(){
                                                if(HelpDuoLei2(strLei: request.mContent, model: model))
                                                {
                                                    if(configModel.mGdmianSi.mIsOn && HelpMianSi(msArray: configModel.mGdmianSi.mGdmianSi, model: model))//固定免死
                                                    {
                                                        strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(固定免死)")
                                                        msArray.append(model)
                                                    }
                                                    else if(configModel.mLcmianSi.mDuoB8 == (index + 1))//楼层免死
                                                    {
                                                        strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(免死\(configModel.mLcmianSi.mDuoB8)楼)")
                                                        msArray.append(model)
                                                    }
                                                    else
                                                    {
                                                        zlArray.append(model)
                                                    }
                                                }
                                            }
                                            
                                            if(zlArray.count == 0){
                                                if(msArray.count > 0)
                                                {
                                                    strContent.append(contentsOf: "\n收益:0")
                                                }
                                                else
                                                {
                                                    strContent = ""
                                                }
                                            }else if((zlArray.count + msArray.count) == 1){
                                                
                                            }else if((zlArray.count + msArray.count) == 2){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB8.mLei2)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei2))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei2 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 3){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB8.mLei3)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei3))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei3 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 4){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB8.mLei4)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei4))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei4 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 5){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB8.mLei5)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei5))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei5 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 6){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB8.mLei6)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei6))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei6 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 7){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB8.mLei7)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei7))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei7 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 8){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB8.mLei8)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei8))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB8.mLei8 * Float(zlArray.count)))")
                                            }else{
                                                strContent = ""
                                            }
                                        }
                                        else
                                        {
                                            strContent = ""
                                        }
                                    }
                                    else
                                    {
                                        strContent = "没有开启多雷8包"
                                    }
                                }else if(request.mTotalNum == 9){
                                    if(configModel.mDuoLei.mB9.mIsOn)
                                    {
                                        var zlArray:Array<HongBaoModel> = Array()
                                        var msArray:Array<HongBaoModel> = Array()
                                        
                                        var flag = true
                                        
                                        request.mContent.forEach { (s) in
                                            
                                            if(!HelpDuoLei(leiInt: s.int!, hbArray: request.mHongBao))
                                            {
                                                flag = false
                                            }
                                        }
                                        
                                        if(flag)
                                        {
                                            strContent = "@\(request.mSenderName)\n发包人:\(request.mSenderName)\n红包总额:\(HelpNum(obj:request.mTotalFee))\n红包个数:\(request.mTotalNum)\n雷:\(request.mContent)"
                                            for (index,model) in request.mHongBao.enumerated(){
                                                if(HelpDuoLei2(strLei: request.mContent, model: model))
                                                {
                                                    if(configModel.mGdmianSi.mIsOn && HelpMianSi(msArray: configModel.mGdmianSi.mGdmianSi, model: model))//固定免死
                                                    {
                                                        strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(固定免死)")
                                                        msArray.append(model)
                                                    }
                                                    else if(configModel.mLcmianSi.mDuoB9 == (index + 1))//楼层免死
                                                    {
                                                        strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))(免死\(configModel.mLcmianSi.mDuoB9)楼)")
                                                        msArray.append(model)
                                                    }
                                                    else
                                                    {
                                                        zlArray.append(model)
                                                    }
                                                }
                                            }
                                            
                                            if(zlArray.count == 0){
                                                if(msArray.count > 0)
                                                {
                                                    strContent.append(contentsOf: "\n收益:0")
                                                }
                                                else
                                                {
                                                    strContent = ""
                                                }
                                            }else if((zlArray.count + msArray.count) == 1){
                                                
                                            }else if((zlArray.count + msArray.count) == 2){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB9.mLei2)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei2))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei2 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 3){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB9.mLei3)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei3))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei3 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 4){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB9.mLei4)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei4))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei4 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 5){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB9.mLei5)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei5))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei5 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 6){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB9.mLei6)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei6))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei6 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 7){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB9.mLei7)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei7))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei7 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 8){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB9.mLei8)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei8))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei8 * Float(zlArray.count)))")
                                            }else if((zlArray.count + msArray.count) == 9){
                                                zlArray.forEach { (model) in
                                                    strContent.append(contentsOf: "\n[\(model.mName)]抢:\(HelpNum(obj:model.mMoney))💣")
                                                }
                                                strContent.append(contentsOf: "\n赔率:\(configModel.mDuoLei.mB9.mLei9)")
                                                strContent.append(contentsOf: "\n每人赔付:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei9))")
                                                strContent.append(contentsOf: "\n总共收益:\(HelpNum(obj: request.mTotalFee * configModel.mDuoLei.mB9.mLei9 * Float(zlArray.count)))")
                                            }else{
                                                strContent = ""
                                            }
                                        }
                                        else
                                        {
                                            strContent = ""
                                        }
                                    }
                                    else
                                    {
                                        strContent = "没有开启多雷9包"
                                    }
                                }else{
                                    strContent = "发包数错误，只支持5-9包！"
                                }
                            }
                        }
                        else
                        {
                            strContent = "雷格式错误"
                        }
                    }
                    else
                    {
                        strContent = "格式错误"
                    }
                }
                else
                {
                    strContent = "配置解析错误，请联系代理"
                }
            }
            else
            {
                strContent = "未设置赔率"
            }
            
            var response = HandleHongBaoResponse()
            response.mContent = strContent
            return try! response.serializedData()
        }else if(msgHeader.cmdid == 1300){
            let request = try! GetOddsConfigRequest(serializedData:body)
            let modelData = CXConfigMgr.shared.getConfig(deviceId: request.mDeviceID)
            if(modelData == nil || modelData.count == 0)
            {
                var response = CXOddsModel()
                var danlei = DanleiModel()
                var danb5 = DANBao5()
                danb5.mIsOn = false
                danb5.mLei1 = 1.0
                danb5.mLei2 = 2.0
                danb5.mLei3 = 3.0
                danb5.mLei4 = 4.0
                danb5.mLei5 = 5.0
                
                var danb6 = DANBao6()
                danb6.mIsOn = false
                danb6.mLei1 = 1.0
                danb6.mLei2 = 2.0
                danb6.mLei3 = 3.0
                danb6.mLei4 = 4.0
                danb6.mLei5 = 5.0
                danb6.mLei6 = 6.0
                
                var danb7 = DANBao7()
                danb7.mIsOn = false
                danb7.mLei1 = 1.0
                danb7.mLei2 = 2.0
                danb7.mLei3 = 3.0
                danb7.mLei4 = 4.0
                danb7.mLei5 = 5.0
                danb7.mLei6 = 6.0
                danb7.mLei7 = 7.0
                
                var danb8 = DANBao8()
                danb8.mIsOn = false
                danb8.mLei1 = 1.0
                danb8.mLei2 = 2.0
                danb8.mLei3 = 3.0
                danb8.mLei4 = 4.0
                danb8.mLei5 = 5.0
                danb8.mLei6 = 6.0
                danb8.mLei7 = 7.0
                danb8.mLei8 = 8.0
                
                var danb9 = DANBao9()
                danb9.mIsOn = false
                danb9.mLei1 = 1.0
                danb9.mLei2 = 2.0
                danb9.mLei3 = 3.0
                danb9.mLei4 = 4.0
                danb9.mLei5 = 5.0
                danb9.mLei6 = 6.0
                danb9.mLei7 = 7.0
                danb9.mLei8 = 8.0
                danb9.mLei9 = 9.0
                
                var duob5 = DUOBao5()
                duob5.mIsOn = false
                duob5.mLei2 = 2.0
                duob5.mLei3 = 3.0
                duob5.mLei4 = 4.0
                duob5.mLei5 = 5.0
                
                var duob6 = DUOBao6()
                duob6.mIsOn = false
                duob6.mLei2 = 2.0
                duob6.mLei3 = 3.0
                duob6.mLei4 = 4.0
                duob6.mLei5 = 5.0
                duob6.mLei6 = 6.0
                
                var duob7 = DUOBao7()
                duob7.mIsOn = false
                duob7.mLei2 = 2.0
                duob7.mLei3 = 3.0
                duob7.mLei4 = 4.0
                duob7.mLei5 = 5.0
                duob7.mLei6 = 6.0
                duob7.mLei7 = 7.0
                
                var duob8 = DUOBao8()
                duob8.mIsOn = false
                duob8.mLei2 = 2.0
                duob8.mLei3 = 3.0
                duob8.mLei4 = 4.0
                duob8.mLei5 = 5.0
                duob8.mLei6 = 6.0
                duob8.mLei7 = 7.0
                duob8.mLei8 = 8.0
                
                var duob9 = DUOBao9()
                duob9.mIsOn = false
                duob9.mLei2 = 2.0
                duob9.mLei3 = 3.0
                duob9.mLei4 = 4.0
                duob9.mLei5 = 5.0
                duob9.mLei6 = 6.0
                duob9.mLei7 = 7.0
                duob9.mLei8 = 8.0
                duob9.mLei9 = 9.0
                
                danlei.mB5 = danb5
                danlei.mB6 = danb6
                danlei.mB7 = danb7
                danlei.mB8 = danb8
                danlei.mB9 = danb9
                
                var duolei = DuoleiModel()
                duolei.mB5 = duob5
                duolei.mB6 = duob6
                duolei.mB7 = duob7
                duolei.mB8 = duob8
                duolei.mB9 = duob9
                
                var gdmiansi = GDMianSiModel()
                gdmiansi.mIsOn = false
                var lcmiansi = LCMianSiModel()
                lcmiansi.mDanB5 = 0
                lcmiansi.mDanB6 = 0
                lcmiansi.mDanB7 = 0
                lcmiansi.mDanB8 = 0
                lcmiansi.mDanB9 = 0
                lcmiansi.mDuoB5 = 0
                lcmiansi.mDuoB6 = 0
                lcmiansi.mDuoB7 = 0
                lcmiansi.mDuoB8 = 0
                lcmiansi.mDuoB9 = 0
                
                response.mDanLei = danlei
                response.mDuoLei = duolei
                response.mGdmianSi = gdmiansi
                response.mLcmianSi = lcmiansi
                
                let respData = try! response.serializedData()
                CXConfigMgr.shared.saveConfig(deviceId: request.mDeviceID, data: respData)
                return respData
            }
            else
            {
                return modelData as! Data
            }
        }else if(msgHeader.cmdid == 1400){
            
            let request = try! SetOddsConfigRequest(serializedData:body)
            let data = try! request.mModel.serializedData()
            CXConfigMgr.shared.saveConfig(deviceId: request.mDeviceID, data: data)
            return Data()
        }
        return Data()
    }
}
